class Solution(object):
    def minSwaps(self, s):
        count = 0
        for c in s:
            if c == '[':
                count += 1
            else:
                count = max(count - 1, 0)
        return (count + 1) // 2